#!/usr/bin/python3
# -*- coding:utf-8 -*-
# __author__ = '__Tony__'
import functools   # 针对带参数的装饰器


def session_begin(func):
    @functools.wraps(func)
    def wrapper(db, **kwargs):  # 指定一毛一样的参数
        #if not db.in_transaction():
            with db.begin():
                return func(db, **kwargs)

    return wrapper
